package operation;

import books.Book;
import books.BookList;

import java.util.Scanner;

public class AddOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
       if(bookList.getBookSize() == bookList.getMaxSize()){
           System.out.println("书架已满，无法添加");
           return ;
       }
        Scanner scan = new Scanner(System.in) ;
        System.out.println("请输入书名:");
        String name = scan.nextLine() ;
        System.out.println("请输入作者:");
        String author = scan.nextLine() ;
        System.out.println("请输入类型:");
        String type = scan.nextLine() ;
        System.out.println("请输入价格");
        int money = scan.nextInt() ;
        Book book = new Book(name,money,author,type) ;
        int tmp = bookList.getBookSize();
        bookList.setBooks(book,tmp++);
        bookList.setBookSize(tmp);
    }




}








